<?php
session_start();
require("../include/db.php");
require("../include/head.php");

?>
<table width="100%">
    <tr>
    	<td width="200" valign="top">
          Administrator option
          <UL>
           <li><a href="allcompanies.php">All companies</a></li>
           <li><a href="report.php">Report</a></li>
          </UL>
   	  </td>   
   	  <td valign="top">
    		<h1>All companies</h1>    		<a href="?order=checked">Order by checked</a> | <a href="?order=recent">Order by Recent singed up</a>
    		<hr>
    		<?php
    		$order =$_GET["order"];
    		$sql="";
    		if ($order == "recent")
    		{ 
    			 $sql= "select * from company order by signupdate desc";
    		}
    		else 	if ($order==checked)
    		{
    		    $sql = "select * from company order by checkedcount desc";
    		}
    		else
    		{
    			$sql = "select * from company";
    		}
    		$conn=getconnection();
   	  	$result=mysql_query($sql,$conn);
   	  	while   ($row=mysql_fetch_array($result))
   	  	{
   	  		  echo "<table width='100%' border='0'>";
   	  		  echo "    <tr>";
   	  		  echo "   	  <td><h3><a href='#' onclick=\"window.open('detail.php?companyid=".$row["id"]."',null,'width=300,height=400');\">>></a>".$row["companyname"]."</td>";
   	  		  echo "      <td><img src='../".$row['logo']."'  width='40'/></td>";
   	  		  echo "      <td>checked:".$row["checkedcount"]."</td>";
   	  		  echo "      <td>signupdate:".$row["signupdate"]."</td>";
   	  		  echo "      <td>";
   	  		  echo "      	<a href='#' onclick=\"window.open('view.php?compayid=".$row["id"]."',null,'width=300,height=400');\">View report</a></td>";
   	  		  echo "    </tr>";
   	  		  echo "</table>";
   	  	}
    		?>
   	  </td>   
   	</tr>
</table>
<?php
require("../include/foot.php");
?>